/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author ori
 */
@Entity
@Table(name = "Clue")
@NamedQueries({@NamedQuery(name = "Clue.findAll", query = "SELECT c FROM Clue c"), @NamedQuery(name = "Clue.findByLevelNo", query = "SELECT c FROM Clue c WHERE c.cluePK.levelNo = :levelNo"), @NamedQuery(name = "Clue.findByClueNo", query = "SELECT c FROM Clue c WHERE c.cluePK.clueNo = :clueNo")})
public class Clue implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CluePK cluePK;
    @Lob
    @Column(name = "clue")
    private String clue;
    @JoinColumn(name = "levelNo", referencedColumnName = "levelNo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private GameLevel gameLevel;

    public Clue() {
    }

    public Clue(CluePK cluePK) {
        this.cluePK = cluePK;
    }

    public Clue(int levelNo, int clueNo) {
        this.cluePK = new CluePK(levelNo, clueNo);
    }

    public CluePK getCluePK() {
        return cluePK;
    }

    public void setCluePK(CluePK cluePK) {
        this.cluePK = cluePK;
    }

    public String getClue() {
        return clue;
    }

    public void setClue(String clue) {
        this.clue = clue;
    }

    public GameLevel getGameLevel() {
        return gameLevel;
    }

    public void setGameLevel(GameLevel gameLevel) {
        this.gameLevel = gameLevel;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cluePK != null ? cluePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Clue)) {
            return false;
        }
        Clue other = (Clue) object;
        if ((this.cluePK == null && other.cluePK != null) || (this.cluePK != null && !this.cluePK.equals(other.cluePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Clue[cluePK=" + cluePK + "]";
    }

}
